﻿using RpcClient.Interface;
using RpcHelper;
using RpcHelper.Error;

namespace RpcSync.Service.Error
{
    /// <summary>
    /// 错误系统-覆盖掉框架内的错误服务    
    /// </summary>
    [RpcClient.Attr.ClassLifetimeAttr(RpcClient.Attr.ClassLifetimeType.单例)]
    internal class ErrorExtendService : IExtendService
    {
        public IUnityCollect _Unity;

        public string Name =>"ErrorService";

        public ErrorExtendService(IUnityCollect unity)
        {
            _Unity = unity;
        }

        private void _Init()
        {
            _Unity.RegisterType(typeof(IErrorEvent), typeof(ErrorEvent), "RpcSync");
            LocalErrorManage.SetAction(() => _Unity.Resolve<IErrorEvent>("RpcSync"));
        }

        public void Load(IRpcService service)
        {
            service.StartUpComplating += this._Init;
        }

    }
}
